const express = require('express');
const app = express();//express contains a bunch of methods;

//1.
app.get('/',(req,res)=>{
    res.send('Hello World from Node.js');
});

//2.
app.get('/example',(req,res)=>{
    res.send('Example from Node.js');
});

//3.
//http://localhost:3000/example/Zicheng/24
    // console.log(req.params);//{ name: 'Zicheng', age: '23' }
    // console.log(req.query);//{}
//http://localhost:3000/example/Zicheng/24?question=answer
    // console.log(req.params);//{ name: 'Zicheng', age: '23' }
    // console.log(req.query);//{ question: 'answer' }
//http://localhost:3000/example/Zicheng/24?question=answer&question2=answer2
    // console.log(req.params);//{ name: 'Zicheng', age: '23' }
    // console.log(req.query);//{ question: 'answer', question2: 'answer2' }
app.get('/example/:name/:age',(req,res)=>{
    console.log(req.params);
    res.send(req.params.name+' : '+req.params.age);
});

app.listen(3000);